
package com.zcp.notepad;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Parcel;
import android.text.style.URLSpan;
import android.view.View;

public class MyURLSpan extends URLSpan {

    public static int TEL = 1;

    public static int EMAIL = 2;

    public static int WEBURL = 3;

    public static int CALENDER = 4;

    private int privateKey = 0;

    public MyURLSpan(Parcel src) {
        super(src);
    }

    public MyURLSpan(int key, String url) {
        super(url);
        privateKey = key;
    }

    @Override
    public void onClick(View widget) {

        if (privateKey == CALENDER) {
            Context context = widget.getContext();
            Intent intent = new Intent();
            intent.setComponent(new ComponentName("com.android.calendar",
                    "com.android.calendar.LaunchActivity"));
            context.startActivity(intent);

        } else {
            super.onClick(widget);
        }
    }

}
